import {Component, Vue} from 'vue-property-decorator'

@Component
export default class Dialog extends Vue {
  // 对话框
  public dialogBox: any = {
    component: '',
    width: '500px',
    visible: false,
    index: -1
  }
  
  /**
   * 创建 dialog
   *
   * @param {Object} [opt] 选项
   * @return {void}
   */
  public openDialogBox(opt?: any): void {
    this.dialogBox.component = 'Create'
    this.$nextTick(() => {
      this.dialogBox.width = opt.width || '500px'
      this.dialogBox.visible = true
    })
  }
  
  /**
   * 关闭 dialog
   *
   * @private
   */
  public closeDialogBox(): void {
    this.dialogBox.visible = false
    setTimeout(() => {
      this.dialogBox.component = ''
      this.dialogBox.index = -1
    }, 350)
  }
}
